//
// Created by javaa on 2021/6/9.
//

#ifndef ALORITHM_C___BASESORT_H
#define ALORITHM_C___BASESORT_H

#include <iostream>


using namespace std;

template<typename T>
class BaseSort {
public:

protected:
    virtual void sort(T arr[], int length) = 0;
    inline bool less(T i, T j) {
        return i > j;
    }

    inline void exchange(T arr[], int i, int j) {
        T t = arr[i];
        arr[i] = arr[j];
        arr[j] = t;
    }

    inline void show(T arr[], int length) {
        for (int i = 0; i < length; ++i) {
            cout << arr[i] << " ";

        }
        cout << endl;
    }

    inline bool isSorted(T arr[], int length) {
        for (int i = 1; i < length; ++i) {
            if (less(arr[i], arr[i - 1])) {
                return false;
            }
        }
        return true;
    }

};


#endif //ALORITHM_C___BASESORT_H
